package com.skycong.hello77.service;

import android.content.Context;
import com.skycong.hello77.R;
import com.skycong.hello77.domain.dto.UserDTO;
import com.skycong.hello77.util.Http;
import com.skycong.hello77.util.Result;
import org.springframework.util.MultiValueMap;

/**
 * user service
 *
 * @author ruanmingcong
 * @date 2018/1/10 8:53
 */
public class UserService {

    private Context context;
    //Android Server IP and Port
    private final String SERURL;
    //Android Server IP and Port
    private final String EMAILSERURL;

    public UserService(Context context) {
        this.context = context;
        //初始化server url
        SERURL = context.getString(R.string.server_url);
        EMAILSERURL = context.getString(R.string.email_server_url);
    }


//    //public Result doLoginUser(String username, String password) {
//        return loginRequest(username, password);
//    }


    /**
     * 发送远程登录请求
     *
     * @param
     * @param
     * @return result对象
     */
    public Result loginRequest(MultiValueMap<String, String> map) {
        return Http.post(SERURL + "/user/login", map, Result.class);
    }

    public Result registerRequest(MultiValueMap<String, String> map) {

        return Http.post(SERURL + "/user/register", map, Result.class);

    }

    public Result checkEmailRequest(String email) {
        return Http.get(SERURL + "/user/check?email=" + email, Result.class);
    }

    /**
     *测试验证码
     *
     * */
    public Result sendCode(MultiValueMap<String, String> map) {
        return Http.post(EMAILSERURL + "/email/send", map, Result.class);
    }


}
